package com.tuyan.aixiang.model;

import java.util.NoSuchElementException;

import androidx.annotation.Nullable;

public class Optional<M> {
    private final M optional;


    public Optional(@Nullable M optional) {
        this.optional = optional;
    }

    public boolean isEmpty(){
        return this.optional == null;
    }

    public M get(){
        if(optional == null) {
            throw new NoSuchElementException("no value present");
        }
        return optional;
    }

    public M getIncludeNull(){
        return optional;
    }
}
